package no.eirikb.bomberman.shared.clientcommand;

import no.eirikb.bomberman.applet.game.Pos;
import no.eirikb.bomberman.shared.Game;
import no.eirikb.bomberman.shared.User;
import no.eirikb.bomberman.applet.game.Way;

/**
 *
 * @author eirikb
 */
public class StartWalkEvent extends ClientEvent {

    private String nick;
    private Way way;
    private Pos lastPos;

    public StartWalkEvent(String nick, Way way, Pos lastPos) {
        this.nick = nick;
        this.way = way;
        this.lastPos = lastPos;
    }

    public void execute(Game game) {
        User user = game.getUsers().get(nick);
        user.setWalking(true);
        user.setWay(way);
        if (lastPos != null) {
            System.out.println("setpos");
            user.setLastPos(lastPos);
        }
    }

    public void execute(User user) {
        user.setWalking(true);
        user.setWay(way);
        if (lastPos != null) {
            user.setLastPos(lastPos);
        }
    }
}
